<div id="columns">
    <div id="center_column" class="center_column">
        <div id="left_column" class="column">
            <?php get_cart();?>
            <?php get_manufacturer();?>
        </div>

        <div style="float: right; width: 690px;">
            <div class="breadcrumb bordercolor">
                <div class="breadcrumb_inner">
                    <a href="<?php echo base_url();?>" title="return to Home">Trang chủ</a>
                    <span class="navigation-pipe">&gt;</span>
                    <?php if ($this->router->method == 'search') :?>
                    <span class="navigation_page">Tìm kiếm sản phẩm</span>
                    <?php else:?>
                        <span class="navigation_page"><a href="<?php echo base_url('san-pham');?>">Sản phẩm</a></span>
                        <?php if (isset($category_info)) :?>
                        <span class="navigation-pipe">&gt;</span>
                        <span class="navigation_page"><a href="<?php echo base_url('san-pham/'.$category_info['category_id'].'_'.url_friendly($category_info['title']));?>"><?php echo $category_info['title'];?></a></span>
                        <?php endif;?>
                    <?php endif;?>
                </div>
            </div>

            <h1>
                <?php if ($this->router->method == 'search') :?>
                Kết quả tìm kiếm
                <?php else:?>
                <?php echo @$category_info['title'];?>&nbsp;
                <?php endif;?>
                <span class="category-product-count">Có tất cả <?php echo count(@$result);?> sản phẩm.</span>
            </h1>

            <!-- <p class="cat_desc bordercolor bgcolor">Thông tin giới thiệu.</p> -->

            <div class="product_sort">
                <form id="productsSortForm" action="">
                    <label for="selectPrductSort">Sắp xếp</label>
                    <select id="selectPrductSort" class="order" url="<?php echo isset($url) ? $url : base_url('san-pham');?>">
                        <option value="position:asc">--</option>
                        <option value="price:asc" <?php echo (@$orderby == 'price_old' && @$orderway=='asc') ? 'selected="selected"' : '';?>>Giá: thấp -> cao</option>
                        <option value="price:desc" <?php echo (@$orderby == 'price_old' && @$orderway=='desc') ? 'selected="selected"' : '';?>>Giá: cao -> thấp</option>
                        <option value="name:asc" <?php echo (@$orderby == 'title' && @$orderway=='asc') ? 'selected="selected"' : '';?>>Tên SP: A -> Z</option>
                        <option value="name:desc" <?php echo (@$orderby == 'title' && @$orderway=='desc') ? 'selected="selected"' : '';?>>Tên SP: Z -> A</option>
                        <option value="quantity:desc" <?php echo (@$orderby == 'quantity') ? 'selected="selected"' : '';?>>Còn hàng</option>
                    </select>
                </form>
                <ul class="product_view">
                    <li id="product_view_grid" class=""></li>
                    <li id="product_view_list" class="current"></li>
                </ul>
            </div>

            <ul id="product_list" class="bordercolor list">
                <?php if (count(@$result) <= 0):?>
                <li style="text-align: center; height: auto;">Hiện tại chưa có sản phẩm nào thuộc danh mục này</li>
                <?php endif;?>
                <?php
                    $temp_category = null;
                    if (isset($result) && count($result) > 0) :
                    foreach($result as $key => $value) :
                        $product_link = base_url('san-pham/'.$value['product_id'].'_'.url_friendly($value['title']).'.html');
                        if (($value['category_id'] != $temp_category) && (count(@$categories) > 1)):
                            $temp_category = $value['category_id'];
                            echo '<div style="clear: both;"></div><div style="font-size: 18px; font-weight: bold; margin-top: 20px; border-top: 0px dashed #CCC; color: #000;">'.@$categories[$value['category_id']].'</div>';
                        endif;
                ?>

                <li class="ajax_block_product bordercolor">
                    <a href="<?php echo $product_link;?>" class="product_img_link" title="<?php echo $value['title'];?>">
                        <img class="img_preview" onerror="ImgError(this);" width="180" height="180" src="<?php echo render_image('/uploads/product/'.$value['product_id'].'/'.md5($value['product_id']).'.jpg', 180, 180, '1.1');?>" alt="<?php echo $value['title'];?>"  href="<?php echo render_image('/uploads/product/'.$value['product_id'].'/'.md5($value['product_id']).'.jpg', 400, 400, '1.1');?>" />
                    </a>
                    <div class="center_block">
                        <div class="product_flags">
                            <span class="new"><?php echo $value['status_flag'] == 0 ? 'Cũ' : 'Mới';?>!</span>
                            <span class="availability bordercolor"><?php echo $value['quantity'] > 0 ? 'Còn hàng' : 'Hết hàng';?></span>
                        </div>
                        <h3><a class="product_link" href="<?php echo $product_link;?>" title="<?php echo $value['title'];?>"><?php echo $value['title'];?></a></h3>
                        <p class="product_desc">
                            <a class="product_descr" href="#" title="<?php echo $value['intro'];?>"></a>
                        </p>
                        <p>
                            <a class="product_descr" href="#" title="<?php echo $value['intro'];?>"><?php echo $value['intro'];?></a>
                        </p>
                    </div>
                    <div class="right_block bordercolor">
                        <span class="price">
                            <?php if ($value['price_old'] <= 0) : ?>
                                <span style="font-size: 11px;">Liên hệ để biết giá</span>
                            <?php else:?>
                                <?php if ($value['price_new'] < $value['price_old']):?>
                                    <span style="text-decoration: line-through; font-size: 16px; font-weight: bold;"><?php echo currency_format($value['price_old']);?> VND</span><br />
                                    <span style="font-size: 16px;  font-weight: bold; <?php echo $value['price_new'] ? 'color: red;' : '';?>"><?php echo currency_format($value['price_new']);?> VND</span>
                                <?php else :?>
                                    <?php echo currency_format($value['price_old']);?> VND
                                <?php endif;?>
                            <?php endif;?>
                        </span>
                        <p class="compare checkbox">
                            <input type="checkbox" class="comparator" id="comparator_item_<?php echo $value['product_id'];?>" value="comparator_item_<?php echo $value['product_id'];?>">
                            <label for="comparator_item_list<?php echo $value['product_id'];?>">So sánh</label>
                        </p>
                        <a class="exclusive ajax_add_to_cart_button" rel="ajax_id_product_<?php echo $value['product_id'];?>" href="<?php echo base_url();?>" title="Thêm vào giỏ">Thêm vào giỏ</a><br>
                        <a class="button" href="<?php echo $product_link;?>" title="View">Xem</a>
                    </div>
                </li>
                <?php endforeach;?>
                <?php endif;?>
            </ul>
            <script type="text/javascript">
            // <![CDATA[
            	var min_item = 'Please select at least one product.';
            	var max_item = "You cannot add more than 2 product(s) in the product comparator";
            //]]>
            </script>
            <form class="product_compare" method="post" action="<?php echo base_url('san-pham/so-sanh');?>" onsubmit="true">
            	<input type="submit" class="button" value="So sánh" id="submit_compare" style="position: fixed; bottom: 10px; right: 10px; display: none;">
            	<input type="hidden" name="compare_product_list" class="compare_product_list" value="">
            </form>
        </div>
    </div>
</div>